function scrollAnimation(currentY, targetY) {
  // currentY  当前滚动条的位置
  //targetY   目标滚动条的位置
  let needScrollTop = targetY - currentY
  let _currentY = currentY
  setTimeout(() => {
    const dist = Math.ceil(needScrollTop / 20)
    _currentY += dist
    window.scrollTo(_currentY, currentY)
    if (needScrollTop > 20 || needScrollTop < -20) {
      scrollAnimation(_currentY, targetY)
    } else {
      window.scrollTo(_currentY, targetY)
    }
  }, 1)
}

module.exports = {
  scrollAnimation
}
